package org.bastion.domain

import org.bastion.domain.adapter._
import org.bastion.domain.message._
import org.bastion.domain.service.impl._

object TestDomain {

  def main(args: Array[String]): Unit = {
    //run
    test
  }

  def run {
    val alertService = new BasicAlertService
    Domain.instance.addAdapter("AlertMessage", new AlertAdapter(alertService))
    var x = Domain.instance ! new AlertMessage("Error in line 18")
    x = Domain.instance ! new AlertMessage("Error in line 27")
        
    println("x = " + x.dummyStatus)
    println("Alerts:")
    alertService.alerts.foreach(s => println("- " + s))
    println("Alerts:")
    alertService.alerts.foreach(s => println("- " + s))
    println("Alerts:")
    alertService.getAlertsClearAfterwards.foreach(s => println("- " + s))
    println("Alerts:")
    alertService.getAlertsClearAfterwards.foreach(s => println("- " + s))
    
    println(new Alert("X123", Level.INFO, "x", "y"))
  }

  def test {
    val properties = System.getProperties
    val propMap = new scala.collection.jcl.Hashtable(properties)
    val propertyFilter = "^java".r
    var map = scala.collection.mutable.Map.empty[String,String]
    propMap filter {
      case (key: String, value) => propertyFilter.findFirstIn(key) != None
    } foreach {
      case (k:String,v:String) => map(k) = v
    }

  }
  
}
